<%@page import="com.wanmait.cookbook.vo.Pager"%>
<%@page import="com.wanmait.cookbook.vo.Works"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
	<%String path=request.getContextPath(); %>
<table class="result-tab" width="100%">
	<tr>
		<th class="tc" width="5%"><input class="allChoose" name=""
			type="checkbox"></th>
		<th>序号</th>
		<th>设置热门</th>
		<th>作品名称</th>
		<th>图片</th>
		<th>上传者</th>
		<th>上传时间</th>
		<th>操作</th>
	</tr>
	<%
	String val = (String) request.getAttribute("val");
	List<Works> Allworks = (List<Works>) request.getAttribute("Allworks");
	for (int i = 0; i < Allworks.size(); i++) {
	%>
	<tr id="tr<%=Allworks.get(i).getId()%>">
		<td class="tc"><input class="choose" name="id[]" type="checkbox"></td>
		<td><%=i + 1%></td>
		<td><select class="sethot" data-userinfoid="<%=Allworks.get(i).getUserinfo().getId() %>"
			data-id="<%=Allworks.get(i).getId()%>" name="hot">
				<%
					if (Allworks.get(i).getHot()) {
				%>
				<option value="1">热门</option>
				<option value="0">不热门</option>
				<%
					} else {
				%>
				<option value="0">不热门</option>
				<option value="1">热门</option>
				<%
					}
				%>
		</select></td>
		<td><%=Allworks.get(i).getTitle()%></td>
		<td><img
			src="<%=path%>/static/image/<%=Allworks.get(i).getPic()%>"
			width="50" height="50"></td>
		<td><%=Allworks.get(i).getUserinfo().getUsername()%></td>
		<td><%=Allworks.get(i).getInputTime()%></td>
		<td><a class="link-del" id="del<%=Allworks.get(i).getId()%>"
			href="javascript:void(0)">删除</a></td>
	</tr>

	<%
		}
	%>
</table>
<div class="list-page">
					<a id="prev" href="javascript:void(0);">上一页</a>
							<!-- 显示数字 -->
							<%Pager pager = (Pager)request.getAttribute("pager"); %>
							<%
							int start = 1;
							int end = pager.getPageCount();
							if(pager.getPageCount()>5)
							{
								start = pager.getPageNo()-2<1?1:pager.getPageNo()-2;
								end = start+4;
								if(end>pager.getPageCount())
								{
									end = pager.getPageCount();
									start = end-4;
								}
							}
							for (int i = start; i <= end; i++) {
								if(pager.getPageNo()!=i){
							%>
							<a class="number" href="javascript:void(0);"><%=i%></a>
							<%
								}else{
							%>
							<a id="pagerColor" class="number" href="javascript:void(0);"><%=i%></a>
							<%
								}
							}
							%>
							<!-- 显示数字的结束 -->
							<a id="next" data-id="<%=pager.getPageNo() %>" href="javascript:void(0);">下一页</a>
							共<%=pager.getPageCount() %>页
						</div>
						<script src="<%=request.getContextPath()%>/manage/js/jquery.min.js"></script>
						<script>
							$(function(){
								$("#pagerColor").css("color","red");
								//下一页
									$("#next").click(function(){
								 	var n =<%=pager.getPageNo()%>
								 	if(n!=<%=pager.getPageCount()%>){
									 $.ajax({
										 url:"<%=request.getContextPath()%>/WorksManageServlet?action=findWorksByInputPager",
											type:"post",
											data:{pageNo:n+1},
											success:function(mes){
								
												$(".result-content").html(mes);
											}
										});//ajax的结束
								 	}
								});
									//上一页
									$("#prev").click(function(){
									 	var n =<%=pager.getPageNo()%>
									 	if(n!=1){
										 $.ajax({
											 url:"<%=request.getContextPath()%>/WorksManageServlet?action=findWorksByInputPager",
												data:{pageNo:n-1},
												success:function(mes){
									
													$(".result-content").html(mes);
												}
											});//ajax的结束
									 	}
									});
							});
						</script>